$(function () {
    require([],function () {
        var $user = $(".user");
        var $pwd = $(".pwd");
        var $again  = $(".again");
        $(".btn").on("click",function () {
            var user = $user.val().trim();
            var pwd = $pwd.val().trim();
            var again = $again.val().trim();

            if(!user){
                window.wxc.xcConfirm("用户名不能为空", window.wxc.xcConfirm.typeEnum.error);
            }else if(pwd.length < 6){
                window.wxc.xcConfirm("密码长度不能小于6", window.wxc.xcConfirm.typeEnum.error);
            }else if(pwd != again){
                window.wxc.xcConfirm("两次面不一致", window.wxc.xcConfirm.typeEnum.error);
            }else{
                $.ajax({
                    url:"/api/register",
                    type:"post",
                    data:{
                        name:user,
                        password:pwd,
                        _app:_app,
                        _cd:_cd
                    },
                    success:function (res) {
                        console.log(res);
                        if(res.code == 1){
                            window.location.href = res.data._url;
                           // window.location.href = '/login?_app='+ _app +'&_cd='+_cd;
                        }
                    }
                });
            }

        });

    })
});